const mongoose = require('mongoose');

const uri = 'mongodb://localhost/cmsDb';

// 创建连接
mongoose.connect(uri);

//使用connetion的连接实例监听连接状态
// 创建连接失败
mongoose.connection.on('error', () => {
  console.log('db error');
})
// 创建连接成功
mongoose.connection.on('open', () => {
  console.log('db connect');
})
